<include file="Public:header" />
<include file="Public:left" />
<style>
    .ncm-goods-gift {
        text-align: left;
    }
    .ncm-goods-gift ul {
        display: inline-block;
        font-size: 0;
        vertical-align: middle;
    }
    .ncm-goods-gift li {
        display: inline-block;
        letter-spacing: normal;
        margin-right: 4px;
        vertical-align: top;
        word-spacing: normal;
    }
    .ncm-goods-gift li a {
        background-color: #fff;
        display: table-cell;
        height: 30px;
        line-height: 0;
        overflow: hidden;
        text-align: center;
        vertical-align: middle;
        width: 30px;
    }
    .ncm-goods-gift li a img {
        max-height: 30px;
        max-width: 30px;
    }

    a.green{

        background: #fff none repeat scroll 0 0;
        border: 1px solid #f5f5f5;
        border-radius: 4px;
        color: #999;
        cursor: pointer !important;
        display: inline-block;
        font-size: 12px;
        font-weight: normal;
        height: 20px;
        letter-spacing: normal;
        line-height: 20px;
        margin: 0 5px 0 0;
        padding: 1px 6px;
        vertical-align: top;
    }

    a.green:hover { color: #FFF; background-color: #1BBC9D; border-color: #16A086; }

    .ncap-order-style .ncap-order-details{
        margin:20px auto;
    }
    .contact-info h3,.contact-info .form_class{
        display: inline-block;
        vertical-align: middle;
    }
    .form_class i.fa{
        vertical-align: text-bottom;
    }
    .ncap-order-details .tabs-panels dt{
        color: #999;
        width: 75px;
        text-align: right;
    }
</style>
<div class="page" style="padding-bottom: 100px">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.go(-1)" title="返回列表"></a>
            <div class="subject">
                <h3>订单打印</h3>
                <!-- <h5>交易订单查询及管理</h5> -->
                <a class="fr" href="{:url('order/index')}">返回订单列表</a>
            </div>

        </div>

    </div>
    <div id="pdf_html">
        <if condition="empty($pdf_html)">
        <style>
            #pdf_html table tr{min-height: 20px;}
            #pdf_html table td{min-height: 20px;padding:9px;text-align: center;border:solid 1px #D7D7D7 }
            .input_text{cursor:pointer}
        </style>
        <div class="ncap-order-style" style="margin-top:0px">
            <div class="ncap-order-details">
                <form id="order-action">
                    <div class="tabs-panels">
                        <div class="misc-info">
                            <div style="height:120px;">
                                <div style="float:left; width:89%; ">
                                    <div class="titile" style="text-align: left;  margin-right:0;  font-size: 25px;height:61px">
                                        
                                        <img style="float:left;" src="__STATIC__/admin/images/logo.png" class="photoup" />
                                        <div style="float:left; margin-top: 12px; ">
                                           深圳燃气
                                            <br/>
                                           <span style="font-size:15px; font-family: Arial"> Shenzhen Gas</span>
                                        </div>
                                        
                                      
                                       
                                    </div>
                                    <div class="titile " style="margin-left:50%; font-weight: 900">
                                        <strong style="font-size: 25px;">送货单</strong>
                                    </div>
                                    <h4>
                                     基本信息
                                    </h4>
                                </div>

                                 <div style="float:right; margin:0; height:100px; width:100px;">
                                        <img style="display: block; width:100%; height: 100%;" src="__STATIC__/admin/images/pinzheng.jpg" class="photoup"  />
                                 </div>
                            
                            </div>
                            <table border="0">
                              <tr>
                                <td>客户：</td>
                                <td>{$order_result['nickname']}</td>
                                <td>送货日期：</td>
                                <td class="input_text">{$order_result['sent_time']}</td>
                                <td>应收货款：</td>
                                <td>{$order_result['total_price']}</td>
                              </tr>
                              <tr>
                                <td>联系电话：</td>
                                <td>{$order_result['address']['mobile']}</td>
                                <td>销售组别：</td>
                                <td>微信商城</td>
                                <td>已收货款：</td>
                                <td>{$order_result['paid_price']}</td>
                              </tr>
                              <tr>
                                <td>订单号：</td>
                                <td>{$order_result['order_sn']}</td>
                                <td>收款方式：</td>
                                <td>微信支付</td>
                                <td>未收货款：</td>
                                <td class="input_text">点击修改内容</td>
                              </tr>
                              <!--<tr>
                                <!-- <td>发票号码：</td>
                                <td class="input_text">点击修改内容</td> -->
                                <!-- <td>业务类型：</td>
                                <td>正常购买</td> 
                                <td>收款方式：</td>
                                <td class="input_text">点击修改内容</td>
                              </tr>-->
                              <tr>
                                <td>安装地址：</td>
                                <td>{$order_result.address.province}{$order_result.address.city}{$order_result.address.country}{$order_result.address.detail}</td>
                                <td>出库单号：</td>
                                <td class="input_text">点击修改内容</td>
                                <td>收款人：</td>
                                <td>深圳燃气集团股份有限公司</td>
                              </tr>
                            </table>
                        </div>
                        <div class="goods-info">
                            <h4>商品信息</h4>
                            <table>
                                <thead>
                                <tr>
                                    <!-- <th>商品id</th> -->
                                    <th>产品编码</th>
                                    <th>产品名称</th>
                                    <th>适用气源</th>
                                    <th>单品价格</th>
                                    <th style="width:60px!important">数量</th>
                                    <th>单品总价</th>
                                    <!-- <th>备注</th> -->
                                </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $total_count = 0;
                                        $total_price = 0; 
                                    ?>
                                    <volist name="order_product" id="vo">
                                        <tr>
                                            <!-- <td class="w60">{$vo.product_id}</td> -->
                                            <td class="w60">{$vo.goods_sn}</td>
                                            <td class="w60">{$vo.product_name}</td>
                                            
                                            <td class="w80"><span class="input_text">点击填写气源类型</span></td>
                                            <td class="w100">{$vo.product_price}</td>
                                            <td class="w60" style="width:60px!important">{$vo.count}</td>
                                            <td class="w100">{$vo.count*$vo.product_price}</td>
                                            <!-- <td class="w100"><span class="input_text">点击修改内容</span></td> -->
                                        </tr>
                                        <?php 
                                            $total_count += $vo['count'];
                                            $total_price += ($vo['count']*$vo['product_price']);
                                        ?>
                                    </volist>
                                    <tr>
                                        <td colspan="4">合计</td>
                                        <td>{$total_count}</td>
                                        <td>{$total_price}</td>

                                    </tr>
                            </table>
                        </div>
                        <div class="total-amount contact-info">
                            <!-- <h3>订单总额：￥{$order_result.total_price}</h3> -->
                        </div>
                        <div class="contact-info">
                            <span style="width:100%;display:inline-block;margin-bottom: 10px">深圳地区，请拨打深圳服务热线：<span class="input_text" style="display:inline-block;width:300px">4008-840-686</span></span></br>
                            <span style="width:100%;display:inline-block;margin-bottom: 10px">备注：<span class="input_text" style="display:inline-block;width:500px">由送货师傅配送金属软管一条，要求下午3点左右上门，谢谢！</span></span></br>
                        </div>
                        <div class="total-amount contact-info">
                            客户签名：________________收货日期：________________
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <else />
        {$pdf_html}
        </if>
    </div>
    <a href="{:url('Order/down_pdf',array('id'=>$id))}" style="display:inline-block;    margin-left: 323px;" type="submit" class="link_btn printing">导出</a>
    <a style="display:inline-block;" type="submit" class="link_btn save">保存</a>
    <input type="hidden" name="id" id="order_id" value="{$id}">
</div>
<script>
    $('.input_text').each(function(){
        if($(this).text() == ''){
            $(this).text('点击修改内容');
        }
    });


    $(".save").click(function(){
        $('.input_text').each(function(){
            if($(this).find('input').length){
                var span_val = $(this).find('input').val();
                $(this).find('input').remove();
                $(this).text(span_val);
            }
        });

        var html = $("#pdf_html").html();
        var order_id = $('#order_id').val();

        $.ajax({
            //请求方式
            type:'POST',
            //发送请求的地址
            url:"{:url('Order/pdf_order')}",
            //服务器返回的数据类型
            dataType:'json',
            //发送到服务器的数据，对象必须为key/value的格式，jquery会自动转换为字符串格式
            data:{html:html,id:order_id},
            success:function(data){
                alert(data.msg);
            },
            error:function(jqXHR){
                //请求失败函数内容
            }
        });
    });

    $('.input_text').click(function(){
        var span_text = $(this).text();
        if(!$(this).find('input').length){
            $(this).empty();
            if(span_text == '点击修改内容')span_text = '';
            if(span_text == '点击填写气源类型')span_text = '';
            $(this).html('<input onblur="input_blur(this)" style="width:100%" value="'+span_text+'">');
        }
    });

    function input_blur(obj){
        var span_val = $(obj).val();
        if(span_val == '')span_val = '点击修改内容';
        $(obj).parent().text(span_val);
        $(obj).remove();
    }
</script>
</body>
</html>